<template>
  <div id="app" style="height: 100%; width: 100%;">
    <div id="nav" style="height: 100%; width: 100%;">
		<el-header style="height: auto;">
			<h3>前台收银系统</h3>
		</el-header>
		 <el-container style="height: 100%;">
			<el-aside style="width: 150px; margin-left: -1%; height: 100%;">
				<el-menu :default-active="activerouter" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
					<router-link to="/"><el-menu-item index="1">首页</el-menu-item></router-link>
					<el-menu-item index="2" @click="historyorder">历史订单</el-menu-item>
					<el-menu-item index="3" @click="locals(3)">菜品管理</el-menu-item>
					<el-menu-item @click="tableadd" index="4">桌位添加</el-menu-item>
				</el-menu>
			</el-aside>
			
			<el-dialog title="桌位添加" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
				<span>
					<el-input type="number" v-model="table" placeholder="请输入桌号"></el-input>
				</span>
				<span slot="footer" class="dialog-footer">
					<el-button @click="canel2">取 消</el-button>
					<el-button type="primary" @click="sure2">确 定</el-button>
			    </span>
			</el-dialog>
			<el-main style="width: 100%;">
				<router-view/>
			</el-main>
		</el-container>
    </div>
  </div>
</template>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 0px 30px 0 0px;

  a {
    font-weight: bold;
    color: #2c3e50;
	text-decoration: none;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
#nav .el-header{
	padding: 15px 20px;
}
.el-container .el-aside{
		padding-top: 35px;
	}
html,body{
	height: 100%;
	overflow-x: hidden;
	overflow-y: hidden;
}
#app #nav a.router-link-exact-active{
	color: #303133;
}
#app #nav a{
	font-weight: normal;
}
</style>
<script>
	export default{
		data(){
			return{
				dialogVisible:false,
				table:"",
				activerouter:"1",
			}
		},
		methods: {
			handleOpen(key, keyPath) {
				console.log(key, keyPath);
			},
			handleClose(key, keyPath) {
				console.log(key, keyPath);
			},
			locals(index){
				 window.location.href=`${this.$locationurl}/#/food/${index}`
			},
			historyorder(){
				window.location.href=`${this.$locationurl}/#/historyorder`
			},
			tableadd(){
				this.dialogVisible=true
			},
			canel2(){
				this.dialogVisible=false
			},
			sure2(){
				this.dialogVisible=false
				var setid= this.table
				if(setid){
					//添加桌号
					this.$axios.get(`${this.$httpurl}/getsetid?setid=${setid}`).then((response)=>{
						if(response.data == "success"){
							this.table="",
							this.$message({
								message: '桌号添加成功！',
								type: 'success'
							})
						}
						if(response.data == "repeat"){
							this.$message.error(`${setid}号桌添加失败！该桌号已存在!`)
						}
					})
				}
				else{
					this.$message.error(`桌号添加失败！请填写正确桌号!`)
				}
			}
		}
	}
</script>
